// packageAPI/pages/system/bluetoothSetting/bluetoothSetting.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    schema: [],
    title: '',
    result: '',
    options: {},
    apiType: '',
    remark: '',
    webUrl: '',
    apiName: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    console.log('options', options)
    wx.setNavigationBarTitle({
      title: options.title,
    })

    this.setData({
      apiType: options.zh,
      title: options.title,
      zh:options.zh,
      remark: options.remark,
      webUrl: options.webUrl
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  },
  openBluetoothFunc(e) {
    let that = this;
    wx.openSystemBluetoothSetting({
      success(res) {
        console.log('设置成功', res)
        that.setData({
          result: res,
          apiName: e.currentTarget.dataset.apiname
        })
      },
      fail(error) {
        console.log('设置失败', error)
        that.setData({
          result: error,
          apiName: e.currentTarget.dataset.apiname
        })
      },
      complete(result) {
        console.log('设置成功或失败继续', result)
        that.setData({
          result: result,
          apiName: e.currentTarget.dataset.apiname
        })
      }
    })
  },
  openAuthorizeFunc(e) {
    let that = this;
    wx.openAppAuthorizeSetting({
      success(res) {
        console.log('设置成功', res)
        that.setData({
          result: res,
          apiName: e.currentTarget.dataset.apiname
        })
      },
      fail(error) {
        console.log('设置失败', error)
        that.setData({
          result: error,
          apiName: e.currentTarget.dataset.apiname
        })
      },
      complete(result) {
        console.log('设置成功或失败继续', result)
        that.setData({
          result: result,
          apiName: e.currentTarget.dataset.apiname
        })
      }
    })
  },
  getWindowInfoFunc(e) {
    console.log('val1111', e.currentTarget.dataset.apiname)
    const windowInfo = wx.getWindowInfo()
    console.log('windowInfo', windowInfo)
    this.setData({
      result: windowInfo,
      apiName: e.currentTarget.dataset.apiname
    })
  },
  getSystemSettingFunc(e) {
    const systemInfo = wx.getSystemSetting()
    console.log('systemInfo', systemInfo)
    this.setData({
      result: systemInfo,
      apiName: e.currentTarget.dataset.apiname
    })
  },
  getSystemInfoSyncFunc(e) {
    const systemInfo = wx.getSystemInfoSync();
    console.log('systemInfo', systemInfo)
    this.setData({
      result: systemInfo,
      apiName: e.currentTarget.dataset.apiname
    })
  },
  getSystemInfoAsyncFunc(e) {
    let that = this;
    wx.getSystemInfoAsync({
      success (res) {
        that.setData({
          result: res,
          apiName: e.currentTarget.dataset.apiname
        })
      },
      fail(error) {
        console.log('设置失败', error)
        that.setData({
          result: error,
          apiName: e.currentTarget.dataset.apiname
        })
      },
      complete(result) {
        console.log('设置成功或失败继续', result)
        that.setData({
          result: result,
          apiName: e.currentTarget.dataset.apiname
        })
      }
    })
  },
  getSystemInfoFunc(e) {
    let that = this;
    wx.getSystemInfo({
      success (res) {
        that.setData({
          result: res,
          apiName: e.currentTarget.dataset.apiname
        })
      },
      fail(error) {
        console.log('设置失败', error)
        that.setData({
          result: error,
          apiName: e.currentTarget.dataset.apiname
        })
      },
      complete(result) {
        console.log('设置成功或失败继续', result)
        that.setData({
          result: result,
          apiName: e.currentTarget.dataset.apiname
        })
      }
    })
  },
  getSkylineInfoSyncFunc(e) {
    const data = wx.getSkylineInfoSync();
    this.setData({
      result: data,
      apiName: e.currentTarget.dataset.apiname
    })
  },
  getSkylineInfoFunc(e) {
    let that = this;
    wx.getSkylineInfo({
      success (res) {
        that.setData({
          result: res,
          apiName: e.currentTarget.dataset.apiname
        })
      },
      fail(error) {
        console.log('设置失败', error)
        that.setData({
          result: error,
          apiName: e.currentTarget.dataset.apiname
        })
      },
      complete(result) {
        console.log('设置成功或失败继续', result)
        that.setData({
          result: result,
          apiName: e.currentTarget.dataset.apiname
        })
      }
    });
  },
  getRendererUserAgentFunc(e) {
    let that = this;
    wx.getRendererUserAgent({
      success (res) {
        that.setData({
          result: res,
          apiName: e.currentTarget.dataset.apiname
        })
      },
      fail(error) {
        console.log('设置失败', error)
        that.setData({
          result: error,
          apiName: e.currentTarget.dataset.apiname
        })
      },
      complete(result) {
        console.log('设置成功或失败继续', result)
        that.setData({
          result: result,
          apiName: e.currentTarget.dataset.apiname
        })
      }
    });
  },
  getDeviceInfoFunc(e) {
    const data = wx.getDeviceInfo();
    this.setData({
      result: data,
      apiName: e.currentTarget.dataset.apiname
    })
  },
  getDeviceBenchmarkInfoFunc(e) {
    let that = this;
    wx.getDeviceBenchmarkInfo({
      success (res) {
        that.setData({
          result: res,
          apiName: e.currentTarget.dataset.apiname
        })
      },
      fail(error) {
        console.log('设置失败', error)
        that.setData({
          result: error,
          apiName: e.currentTarget.dataset.apiname
        })
      },
      complete(result) {
        console.log('设置成功或失败继续', result)
        that.setData({
          result: result,
          apiName: e.currentTarget.dataset.apiname
        })
      }
    });
  },
  getAppBaseInfoFunc(e) {
    const data = wx.getAppBaseInfo();
    this.setData({
      result: data,
      apiName: e.currentTarget.dataset.apiname
    })
  },
  getAppAuthorizeSettingFunc(e) {
    const data = wx.getAppAuthorizeSetting();
    this.setData({
      result: data,
      apiName: e.currentTarget.dataset.apiname
    })
  }
})